package org.healthy.controller;

import org.healthy.controller.base.BaseController;
import org.healthy.model.user.Paper;
import org.healthy.model.user.Shiti;
import org.healthy.service.IPaperService;
import org.healthy.service.IShitiService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by qingshengzheng on 17/10/11.
 */
@Controller
@RequestMapping("/api")
public class ShitiController extends BaseController {
    @Resource(name = "paperService")
    private IPaperService paperService;
    @Resource(name="shitiService")
    private IShitiService shitiService;

    /**
     * 根据试题id获取id
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/v1/shiti/getShiti", method = RequestMethod.POST)
    public String getShiti(@RequestParam String id) {
        Shiti v = shitiService.getShitiByid( id);
        return response(v);
    }

    /**
     *获取试卷下的试题
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/v1/shiti/shitiOfPaper", method = RequestMethod.POST)
    public String getShiTiOfpaper(@RequestParam String id) {
        List<Shiti>shitis= shitiService.getShitiOfPaper(id);
        return response(shitis);
    }

    /**
     * 搜索试题
     * @param shiti
     * @return
     */
    @ResponseBody
        @RequestMapping(value = "/v1/shiti/searchPaper", method = RequestMethod.POST)
    public String searchShiti(@RequestBody Shiti shiti) {
        List<Shiti>shitis= shitiService.searchShiti(shiti);
        return response(shitis);
    }




}
